********************************
*** BOTTOM PANEL, MAY+ORG CPS **
********************************

*** COLUMNS 1,2 **

clear all 
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/

use $folder/aux_may-org.dta

keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988)
keep if classer == 1 | classer == 2
keep if age >= 25 & age <= 59
keep if ethnic == 8
keep if male == 1
keep if logearnwke > 0

keep if smsarank == 26 | smsarank == 57 | smsarank == 33 | smsarank == 38 | smsarank == 19 | smsarank == 24

collapse (mean) logearnwke loguearnhre [pw=earnwt], by(year smsarank)

/* smoothing */
xtset smsarank year
tssmooth ma loguearnhre_sm = loguearnhre, window(1 1 1)
drop loguearnhre
rename loguearnhre_sm loguearnhre
*		*/

reshape wide logearnwke loguearnhre, i(year) j(smsarank)
rename (logearnwke26 loguearnhre26) (logearnwke_mia loguearnhre_mia)

/* Borjas Synthetic Control */
* See Appendix Table A1 in Borjas 2015 (i.e., first paper)
gen logearnwke_bor = .296 * logearnwke24 + .497 * logearnwke19 + .207 * logearnwke38
gen loguearnhre_bor = .296 * loguearnhre24 + .497 * loguearnhre19 + .207 * loguearnhre38

keep year loguearnhre_bor loguearnhre_mia
rename (loguearnhre_bor loguearnhre_mia) (column1_2 loguearnhre_mia_column_1_2)
tempfile edno
save `edno'

*** COLUMN 3 **

clear
use $folder/aux_may-org.dta
set scheme s1color

keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988)
keep if classer == 1 | classer == 2
keep if age >= 25 & age <= 59
keep if ethnic == 8
keep if male == 1
keep if logearnwke > 0

keep if smsarank == 26 | smsarank == 38 | smsarank == 19 | smsarank == 24 | smsarank == 1 | smsarank == 12 | smsarank == 32

collapse (mean) loguearnhre [pw=earnwt], by(year smsarank)
reshape wide loguearnhre, i(year) j(smsarank)
rename ( loguearnhre26) ( loguearnhre_mia)

/* Borjas Synthetic Control */
* See Appendix Table A1 in Borjas 2015 (i.e., first paper)
gen loguearnhre_bor = .296 * loguearnhre24 + .497 * loguearnhre19 + .207 * loguearnhre38

keep year loguearnhre_bor loguearnhre_mia
rename (loguearnhre_bor loguearnhre_mia) (column3 loguearnhre_mia_column3)
tempfile dve
save `dve'


*** COLUMNS 4,5 **

use $folder/aux_may-org.dta, clear

keep if age >= 19 & age <= 65
keep if cuban == 0
keep if low_skilled == 1
drop if (ftpt79 == 0 & year <= 1988) | (ftpt89 ==1 & year > 1988) 
keep if classer == 1 | classer == 2 

collapse (mean) loguearnhre [pw=earnwt], by(year smsarank)
reshape wide loguearnhre, i(year) j(smsarank)

gen loguearnhre_our = .61 * loguearnhre28 + .209 * loguearnhre36 + .181 * loguearnhre53  // this is borjas vars our sample
gen loguearnhre_our2 = .3 * loguearnhre1 + .25 * loguearnhre12 + .45 * loguearnhre32  // this is our sample our synth
keep year loguearnhre26 loguearnhre_our loguearnhre_our2

rename (loguearnhre26 loguearnhre_our loguearnhre_our2) (loguearnhre_mia_column4_5 column4 column5)
tempfile tri
save `tri'

******************
******************
******************
clear
use `edno'
merge 1:1 year using `dve', nogen
merge 1:1 year using `tri', nogen

rename (loguearnhre_mia_column_1_2 loguearnhre_mia_column3 loguearnhre_mia_column4_5 column1_2 column3 column4 column5) ///
	(logwage1 logwage2 logwage3 logwage4 logwage5 logwage6 logwage7)

reshape long logwage, i(year) j(city)

estimates clear
drop if year == 1980

/* Columns 1,2 */
preserve
gen pre = year < 1979
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 1 | city == 4
gen mia = city == 1
gen synthetic = city == 4

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapost* i.year i.city if year > 1976, robust // this is column 1
estimates store one
reg logwage miapre* miapost* i.year i.city, robust  // this is column 2
estimates store two
restore

/* Column 3 */
preserve
gen pre = year < 1979
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 2 | city == 5
gen mia = city == 2
gen synthetic = city == 5

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 3
estimates store three
restore

/* Column 5 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983 
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 3 | city == 6
gen mia = city == 3
gen synthetic = city == 6

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 5
estimates store four
restore

/* Column 6 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983 
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 3 | city == 7
gen mia = city == 3
gen synthetic = city == 7

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 6
estimates store five
restore

*********************
*********************
*********************

estimates table one two three four five, keep(m*) b(%4.3f) se(%4.3f) stats(r2 N)
estimates table one two three four five, keep(m*) b(%4.3f) star stats(r2 N)
